package com.ihr360.alps.api;


import com.ihr360.commons.specification.Ihr360Predication;
import com.ihr360.commons.specification.PredicationOperator;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;


/**
 * 通过ids list和其他条件限定获取数据
 * @param <T>
 */
public class IDListWithCriteriaRequest<T> implements Serializable{
    List<T> ids;
    List<Ihr360Predication> predications;

    public IDListWithCriteriaRequest() {
    }

    public IDListWithCriteriaRequest(List<T> ids) {
        this.ids = ids;
    }

    public IDListWithCriteriaRequest(Collection<T> ids) {
        if (ids instanceof List){
            this.ids = (List)ids;
        }else{
            this.ids = new ArrayList<>(ids);
        }
    }

    public List<T> getIds() {
        return ids;
    }

    public void setIds(List<T> ids) {
        this.ids = ids;
    }

    public List<Ihr360Predication> getPredications() {
        return predications;
    }

    public void setPredications(List<Ihr360Predication> predications) {
        this.predications = predications;
    }

    public  void addPredication(String field,String value,PredicationOperator operator){
        if (this.predications==null){
            this.predications = new ArrayList<>();
        }
        this.predications.add(new Ihr360Predication(field,value,operator));
    }
}